<?php

namespace App\Http\Model;

use Illuminate\Database\Eloquent\Model;

class ProductTagModel extends Model
{
    protected $table = 'pre_product_tag';

    public function Product(){
        return $this->belongsTo("App\Http\Model\ProductModel");
    }

    public function Img(){
        return $this->hasOne("App\Http\Model\ImgModel","imgId","value");
    }

    public function addProductTag($productTag){
        $res = \DB::table("pre_product_tag")->insertGetId($productTag);

        return $res;
    }

    public function updateProductTag($productTag){
        $res = \DB::table("pre_product_tag")->where("id",$productTag["id"])->update($productTag);

        return $res;
    }

    public function delProductTag($id){
        $res = \DB::table("pre_product_tag")->where("id",$id)->update([
            "states"=>9
        ]);

        return $res;
    }

    public function selectProductTag($id){
        $res = \DB::table("pre_product_tag")->where("id",$id)->where("states","!=",9)->get();

        return $res;
    }
}
